stylistic changes

Umar M. Sheikh 11 年之前
父节点
当前提交
05a4f1aa34
共有 1 个文件被更改,包括 14 次插入5 次删除
  1. 14 5
      spec/models/agents/public_transport_agent_spec.rb

+ 14 - 5
spec/models/agents/public_transport_agent_spec.rb

@@ -2,8 +2,8 @@ require 'spec_helper'
2 2
 describe Agents::PublicTransportAgent do
3 3
   before do
4 4
     valid_params = {
5
-    "name" => "sf muni agent",
6
-    "options" => {
5
+      "name" => "sf muni agent",
6
+      "options" => {
7 7
         "alert_window_in_minutes" => "20",
8 8
         "stops" => ['N|5221', 'N|5215'],
9 9
         "agency" => "sf-muni"
@@ -13,6 +13,7 @@ describe Agents::PublicTransportAgent do
13 13
     @agent.user = users(:bob)
14 14
     @agent.save!
15 15
   end
16
+
16 17
   describe "#check" do
17 18
     before do
18 19
       stub_request(:get, "http://webservices.nextbus.com/service/publicXMLFeed?a=sf-muni&command=predictionsForMultiStops&stops=N%7C5215").
@@ -20,19 +21,28 @@ describe Agents::PublicTransportAgent do
20 21
          to_return(:status => 200, :body => File.read(Rails.root.join("spec/data_fixtures/public_transport_agent.xml")), :headers => {})
21 22
       stub(Time).now {"2014-01-14 20:21:30 +0500".to_time}
22 23
     end
24
+
23 25
     it "should create 4 events" do
24 26
       lambda { @agent.check }.should change {@agent.events.count}.by(4)
25 27
     end
28
+
26 29
     it "should add 4 items to memory" do
27 30
       @agent.memory.should == {}
28 31
       @agent.check
29
-      @agent.memory.should == {"existing_routes" => [{"stopTag"=>"5221", "tripTag"=>"5840324", "epochTime"=>"1389706393991", "currentTime"=>"2014-01-14 20:21:30 +0500"}, {"stopTag"=>"5221", "tripTag"=>"5840083", "epochTime"=>"1389706512784", "currentTime"=>"2014-01-14 20:21:30 +0500"}, {"stopTag"=>"5215", "tripTag"=>"5840324", "epochTime"=>"1389706282012", "currentTime"=>"2014-01-14 20:21:30 +0500"}, {"stopTag"=>"5215", "tripTag"=>"5840083", "epochTime"=>"1389706400805", "currentTime"=>"2014-01-14 20:21:30 +0500"}]
32
+      @agent.memory.should == {"existing_routes" => [
33
+          {"stopTag"=>"5221", "tripTag"=>"5840324", "epochTime"=>"1389706393991", "currentTime"=>"2014-01-14 20:21:30 +0500"},
34
+          {"stopTag"=>"5221", "tripTag"=>"5840083", "epochTime"=>"1389706512784", "currentTime"=>"2014-01-14 20:21:30 +0500"},
35
+          {"stopTag"=>"5215", "tripTag"=>"5840324", "epochTime"=>"1389706282012", "currentTime"=>"2014-01-14 20:21:30 +0500"},
36
+          {"stopTag"=>"5215", "tripTag"=>"5840083", "epochTime"=>"1389706400805", "currentTime"=>"2014-01-14 20:21:30 +0500"}
37
+        ]
30 38
       }
31 39
     end
40
+
32 41
     it "should not create events twice" do
33 42
       lambda { @agent.check }.should change {@agent.events.count}.by(4)
34 43
       lambda { @agent.check }.should_not change {@agent.events.count}
35 44
     end
45
+
36 46
     it "should reset memory after 2 hours" do
37 47
       lambda { @agent.check }.should change {@agent.events.count}.by(4)
38 48
       stub(Time).now {"2014-01-14 20:21:30 +0500".to_time + 3.hours}
@@ -40,6 +50,7 @@ describe Agents::PublicTransportAgent do
40 50
       lambda { @agent.check }.should change {@agent.events.count}.by(4)
41 51
     end
42 52
   end
53
+
43 54
   describe "validation" do
44 55
     it "should validate presence of stops" do
45 56
       @agent.options['stops'] = nil
@@ -55,7 +66,5 @@ describe Agents::PublicTransportAgent do
55 66
       @agent.options['alert_window_in_minutes'] = ""
56 67
       @agent.should_not be_valid
57 68
     end
58
-
59 69
   end
60
-
61 70
 end